From: Keir Fraser Date: Wed, 23 Jun 2010 22:23:22 +0000 (+0100) Subject: tmem: skip special case in alloc_heap_pages() if tmem holds no pages X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~11887 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=89784f9469174e6b30cfcfa74162d45f268d366a;p=xen.git tmem: skip special case in alloc_heap_pages() if tmem holds no pages Signed-off-by: Dan Magenheimer --- diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 6a1b6bde72..10c6b22093 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -316,11 +316,14 @@ static struct page_info *alloc_heap_pages( spin_lock(&heap_lock); /* - * TMEM: When available memory is scarce, allow only mid-size allocations - * to avoid worst of fragmentation issues. Others try TMEM pools then fail. + * TMEM: When available memory is scarce due to tmem absorbing it, allow + * only mid-size allocations to avoid worst of fragmentation issues. + * Others try tmem pools then fail. This is a workaround until all + * post-dom0-creation-multi-page allocations can be eliminated. */ if ( opt_tmem && ((order == 0) || (order >= 9)) && - (total_avail_pages <= midsize_alloc_zone_pages) ) + (total_avail_pages <= midsize_alloc_zone_pages) && + tmem_freeable_pages() ) goto try_tmem; /* diff --git a/xen/common/tmem.c b/xen/common/tmem.c index a3f236ae0b..b917fae522 100644 --- a/xen/common/tmem.c +++ b/xen/common/tmem.c @@ -2850,6 +2850,11 @@ EXPORT void *tmem_relinquish_pages(unsigned int order, unsigned int memflags) return pfp; } +EXPORT unsigned long tmem_freeable_pages(void) +{ + return tmh_freeable_pages(); +} + /* called at hypervisor startup */ static int __init init_tmem(void) { diff --git a/xen/include/xen/tmem.h b/xen/include/xen/tmem.h index 9140b08847..cc19110505 100644 --- a/xen/include/xen/tmem.h +++ b/xen/include/xen/tmem.h @@ -11,6 +11,7 @@ extern void tmem_destroy(void *); extern void *tmem_relinquish_pages(unsigned int, unsigned int); +extern unsigned long tmem_freeable_pages(void); extern int opt_tmem; #endif /* __XEN_TMEM_H__ */